package handler

import (
	"github.com/gin-gonic/gin"
	"zg3zk3/api/request"
	"zg3zk3/interface/dao"
	"zg3zk3/interface/models"
)

func FsAdd(context *gin.Context) {
	var req request.FsReq
	if err := context.ShouldBind(&req); err != nil {
		context.JSON(200, gin.H{
			"code": "code",
			"msg":  err.Error(),
			"data": nil,
		})
		return
	}

	Fs := models.Denshis{
		Id:        context.GetUint("userId"),
		Name:      req.Name,
		Friendnum: req.Friendnum,
	}

	dao.ZbjCreate(&Fs)

	context.JSON(200, gin.H{
		"code": "code",
		"msg":  "粉丝添加成功",
		"data": Fs,
	})

}

func FsShow(context *gin.Context) {
	var req request.ShowReq
	if err := context.ShouldBind(&req); err != nil {
		context.JSON(200, gin.H{
			"code": "code",
			"msg":  err.Error(),
			"data": nil,
		})
		return
	}

	var show models.Denshis

	dao.FindLogin(&show, &show)

	context.JSON(200, gin.H{
		"code": "code",
		"msg":  show,
		"data": nil,
	})

}

func FsDelete(context *gin.Context) {
	var req request.DeleteReq
	if err := context.ShouldBind(&req); err != nil {
		context.JSON(200, gin.H{
			"code": "code",
			"msg":  err.Error(),
			"data": nil,
		})
		return
	}
	ui := context.GetUint("userId")

	var delete models.Denshis
	dao.Deleted(ui, &models.Denshis{
		Id: ui,
	})

	context.JSON(200, gin.H{
		"code": "code",
		"msg":  delete,
		"data": nil,
	})
}
